<div class="statisticsPlayers index">
<h2><?php __('Players Statistics');?></h2>
<p>
<?php

$paginator->options(array('url' => $this->passedArgs));

$options = array('url' => array(
	'sort' => null,
	'direction' => null,
	'page' => empty($this->passedArgs['page']) ? 1 : $this->passedArgs['page']
));

$fields = array(
	'Player.strName' => array(
		'title' => __('Player', true),
		'description' => __('Player', true),
		'direction' => 'asc'),
	'Team.strName' => array(
		'title' => __('Team', true),
		'description' => __('Team', true),
		'direction' => 'asc'),
	'StatisticsPlayer.iMatchPlayed' => array(
		'title' => __('GP', true),
		'description' => __('Game Played', true),
		'direction' => 'desc'),
	'StatisticsPlayer.iMVP' => array(
		'title' => __('MVP', true),
		'description' => __('Most Valuable Player', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iPasses' => array(
		'title' => __('Pa', true),
		'description' => __('Passes', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iCatches' => array(
		'title' => __('Ca', true),
		'description' => __('Catches', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iInterceptions' => array(
		'title' => __('Int', true),
		'description' => __('Interceptions', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iTouchdowns' => array(
		'title' => __('Td', true),
		'description' => __('Touchdowns', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iCasualties' => array(
		'title' => __('Cas', true),
		'description' => __('Casualties', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iTackles' => array(
		'title' => __('Tac', true),
		'description' => __('Tackles', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iKO' => array(
		'title' => __('KO', true),
		'description' => __('Catches', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iStuns' => array(
		'title' => __('St', true),
		'description' => __('Stuns', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iInjuries' => array(
		'title' => __('Inj', true),
		'description' => __('Injuries', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iDead' => array(
		'title' => __('Dd', true),
		'description' => __('Dead', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iMetersRunning' => array(
		'title' => __('MR', true),
		'description' => __('Meters Running', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_iMetersPassing' => array(
		'title' => __('MP', true),
		'description' => __('Meters Passing', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iInterceptions' => array(
		'title' => __('sInt', true),
		'description' => __('Sustained Interceptions', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iCasualties' => array(
		'title' => __('sCas', true),
		'description' => __('Sustained Casualties', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iTackles' => array(
		'title' => __('sTac', true),
		'description' => __('Sustained Tackles', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iKO' => array(
		'title' => __('sKO', true),
		'description' => __('Sustained KO', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iStuns' => array(
		'title' => __('sSt', true),
		'description' => __('Sustained Stuns', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_iInjuries' => array(
		'title' => __('sInj', true),
		'description' => __('Sustained Injuries', true),
		'direction' => 'desc'),


	'StatisticsPlayer.Inflicted_fAvgPasses' => array(
		'title' => __('AvgPa', true),
		'description' => __('Passes by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgCatches' => array(
		'title' => __('AvgCa', true),
		'description' => __('Catches by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgInterceptions' => array(
		'title' => __('AvgInt', true),
		'description' => __('Interceptions by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgTouchdowns' => array(
		'title' => __('AvgTd', true),
		'description' => __('Touchdowns by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgCasualties' => array(
		'title' => __('AvgCas', true),
		'description' => __('Casualties by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgTackles' => array(
		'title' => __('AvgTac', true),
		'description' => __('Tackles by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgKO' => array(
		'title' => __('AvgKO', true),
		'description' => __('Catches by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgStuns' => array(
		'title' => __('AvgSt', true),
		'description' => __('Stuns by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgInjuries' => array(
		'title' => __('AvgInj', true),
		'description' => __('Injuries by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgDead' => array(
		'title' => __('AvgDd', true),
		'description' => __('Dead by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgMetersRunning' => array(
		'title' => __('AvgMR', true),
		'description' => __('Meters Running by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Inflicted_fAvgMetersPassing' => array(
		'title' => __('AvgMP', true),
		'description' => __('Meters Passing by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgInterceptions' => array(
		'title' => __('AvgsInt', true),
		'description' => __('Sustained Interceptions by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgCasualties' => array(
		'title' => __('AvgsCas', true),
		'description' => __('Sustained Casualties by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgTackles' => array(
		'title' => __('AvgsTac', true),
		'description' => __('Sustained Tackles by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgKO' => array(
		'title' => __('AvgsKO', true),
		'description' => __('Sustained KO by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgStuns' => array(
		'title' => __('AvgsSt', true),
		'description' => __('Sustained Stuns by Game', true),
		'direction' => 'desc'),
	'StatisticsPlayer.Sustained_fAvgInjuries' => array(
		'title' => __('AvgsInj', true),
		'description' => __('Sustained Injuries by Game', true),
		'direction' => 'desc'),
);

$current = empty($this->passedArgs['sort'])?'StatisticsPlayer.Inflicted_iTouchdowns':$this->passedArgs['sort'];
$fields[$current]['direction'] = (empty($this->passedArgs['direction']) || $this->passedArgs['direction'] == 'desc')?'asc' : 'desc';
$fields[$current]['title'] = '>'.$fields[$current]['title'].'<';

echo $paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
<?php
foreach ( $fields as $key => $value ) {
	$options['url']['sort'] = $key;
	$options['url']['direction'] = $fields[$key]['direction'];

	echo '<th><acronym title="'.$fields[$key]['description'].'">';
	echo $paginator->sort($fields[$key]['title'], $key, $options);
	echo '</acronym></th>';
}
?></th>
</tr>
<?php
$i = 0;
foreach ($statisticsPlayers as $statisticsPlayer):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td><?php echo $html->link($statisticsPlayer['Player']['strName'], array('controller' => 'players', 'action' => 'view', $statisticsPlayer['Player']['ID'])); ?></td>
		<td><?php echo $html->link($statisticsPlayer['Player']['Team']['strName'], array('controller' => 'teams', 'action' => 'view', $statisticsPlayer['Player']['Team']['ID'])); ?></td>
<?php
		foreach ( $statisticsPlayer['StatisticsPlayer'] as $key => $value ) {
			switch ( $key ) {
				case 'ID':
				case 'idPlayer_Listing':
				case 'Sustained_iDead':
					break;
				default:
					if(ereg("fAvg", $key)) {
						$value = $number->precision($value,1);
					}
					echo '<td>'.$value.'</td>';
					break;
			}

		}
?>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
